<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use EasyWeChat\Foundation\Application;

class AppletsController extends Controller
{
  // 验证
  public function index(Request $request)
  {
    $options = [
      'debug'  => true,
      'mini_program' => [
          'app_id'   => env('APPLETS_APP_ID'),
          'secret'   => env('APPLETS_APP_SECRET'),
          'token'    => env('APPLETS_APP_TOKEN'),
          'aes_key'  => env('APPLETS_APP_AES_KEY'),
        ],
      'log' => [
        'level' => 'debug',
        'file'  => '/var/www/wechat/storage/logs/applets.log',
      ],
    ];
    $app = new Application($options);
    $userService = $app->user;

    $response = $app->server->serve();
    // 将响应输出
    return $response;
  }
}
